import axios from 'axios'
import store from '@/store'
const request = axios.create({
  baseURL: 'http://likede2-admin.itheima.net/likede'
})
// 请求拦截器
request.interceptors.request.use(config => {
  // config 是请求的配置信息
  if (store.getters.userToken) {
    config.headers['Authorization'] = `${store.getters.userToken}` // 注入token
  }
  return config // 必须要返回
}, error => {
  return Promise.reject(error)
})
export default request
